package com.example.jiaopin.Service;

import com.example.jiaopin.model.CourseEvaluation;
import com.example.jiaopin.Mapper.CourseEvaluationMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CourseEvaluationService {

    @Autowired
    private CourseEvaluationMapper courseEvaluationMapper;

    // 添加课程评价
    public int addCourseEvaluation(CourseEvaluation courseEvaluation) {
        return courseEvaluationMapper.insert(courseEvaluation);
    }

    // 删除课程评价
    public int deleteCourseEvaluation(Integer evaluationId) {
        return courseEvaluationMapper.deleteById(evaluationId);
    }

    // 获取课程的所有评价
    public List<CourseEvaluation> getEvaluationsByCourseId(Integer courseId) {
        return courseEvaluationMapper.selectByCourseId(courseId);
    }
}
